﻿using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class NewsBlastScript {

	/* Interface to native implementation */
	#if UNITY_IOS
	[DllImport ("__Internal")]
	private static extern void _SetGameObjectNameForNB(string gameObjectName);

	[DllImport ("__Internal")]
	private static extern void _StartNews(bool isDebugMode = false);

	[DllImport ("__Internal")]
	private static extern void _CancelShowNewsBlast();
	#endif

	public void SetGameObjectNameForNB(string gameObjectName) 
	{
		// Call plugin only when running on real device
		if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) {
			#if UNITY_ANDROID
			SSCInternalAdapter.getInstance().setGameObjName(gameObjectName);
			#elif UNITY_IOS
			_SetGameObjectNameForNB(gameObjectName);
			#endif
		}
	}

	public void StartNews(bool isDebugMode = false)
	{
		// Call plugin only when running on real device
		if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) {
			#if UNITY_ANDROID
			SSCInternalAdapter.getInstance().doNewsBlast();
			#elif UNITY_IOS
			_StartNews(isDebugMode);
			#endif
		}
	}

	public void CancelShowNewsBlast()
	{
		// Call plugin only when running on real device
		if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android) {
			#if UNITY_ANDROID
			SSCInternalAdapter.getInstance().cancelShowNewsBlast();
			#elif UNITY_IOS
			_CancelShowNewsBlast();
			#endif
		}
	}

}

